<template>
  <el-dialog title="客户跟进记录" :visible.sync="dialogVisible" width="40%">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-form-item label="跟进内容" prop="traceCustomerContent">
        <el-input
          type="textarea"
          v-model="form.traceCustomerContent"
          :rows="3"
        ></el-input>
      </el-form-item>
      <el-form-item label="下次跟进时间" prop="traceCustomerNextTime">
        <el-date-picker
          clearable
          style="width: 100%"
          v-model="form.traceCustomerNextTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择下次跟进时间"
        >
        </el-date-picker>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { addCrmCustomerTrace } from "@/api/crm/customer";

export default {
  data() {
    return {
      dialogVisible: false,
      // 表单参数
      form: {},
      rules: {
        traceCustomerContent: [
          { required: true, message: "跟进内容不能为空", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    open(row) {
      this.form = {}
      this.dialogVisible = true;
      this.form.customerId = row.customerId
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          addCrmCustomerTrace(this.form).then((response) => {
            this.$modal.msgSuccess("新增成功");
            this.dialogVisible = false;
            this.$parent.getList();
          });
        }
      });
    },
  },
};
</script>